import cgi
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.api import users
from entities import *
from Entities import *


def Add(roleName):
    role = db.GqlQuery("SELECT * FROM Role WHERE RoleName = :1",roleName)
    if role.count() == 0:
        role = Role(RoleName = roleName)
        role.put()
        return "Complete"
    else :
        return "No ..."
def Get():
    role_list = []
    roles = db.GqlQuery("SELECT * FROM Role")
    for role in roles:
        role_dict = {}
        role_dict["RoleName"] = role.RoleName
        role_dict["RoleID"] = role.key().id()
        role_list.append(role_dict)
    tuple_role = tuple(role_list)
    return tuple_role
    
def GetID(roleName):
    roles = Role.gql('WHERE RoleName = :1',roleName)
    if roles.count()!= 0:
        for role in roles:
            RoleID = role.key().id()
    else:
        RoleID = None
    return RoleID